import {
	createRouter,
	createWebHistory
} from 'vue-router'
import Layout from '../components/Layout/index.vue'
const routes = [{
		path: '/',
		name: 'app',
		// 重定向
		redirect: to => {
			return {
				path: '/home'
			}
		},
		component: Layout,
		children: [{
				path: '/home',
				name: 'home',
				component: () => import('../views/Home/index.vue'),
			},
			{
				path: '/login',
				name: 'login',
				component: () => import('../views/Auth/login.vue'),
			},
			{
				path: '/register',
				name: 'register',
				component: () => import('../views/Auth/register.vue'),
			},
			{
				path: '/article',
				name: 'article',
				component: () => import('../views/Article/list.vue')
			},
			{
				path: '/myArticle',
				name: 'myArticle',
				component: () => import('../views/Article/list.vue')
			},
			{
				path: '/publish',
				name: 'Publish',
				component: () => import('../views/Article/publish.vue')
			},
			{
				path: '/detail',
				name: 'Detail',
				component: () => import('../views/Article/detail.vue')
			},
			{
				path: '/user',
				name: 'User',
				component: () => import('../views/User/index.vue')
			},
			{
				path: '/profile',
				name: 'Profile',
				component: () => import('../views/User/profile.vue')
			}
		]
	},
	{
		path: '/:pathMatch(.*)',
		name: '404',
		component: () => import('../views/Error/404.vue')
	}

]

const router = createRouter({
	history: createWebHistory(),
	routes
})

export default router
